package com.guqj.redis.subscribe;

import redis.clients.jedis.JedisPubSub;

public class RedisMsgPubSubListener extends JedisPubSub {

	/**
	 * 监听到订阅频道接受到消息时的回调
	 */
	@Override
	public void onMessage(String channel, String message) {
		System.out.println("channel:" + channel + " receives message :" + message);
		super.onMessage(channel, message);
	}

	/**
	 * 监听到订阅模式接受到消息时的回调
	 */
	@Override
	public void onPMessage(String pattern, String channel, String message) {
		System.out.println("onPMessage:[pattern:" + pattern + ", channel:" + channel + ", message:" + message + "]");
		super.onPMessage(pattern, channel, message);
	}

	/**
	 * 订阅频道时的回调
	 */
	@Override
	public void onSubscribe(String channel, int subscribedChannels) {
		System.out.println("channel:" + channel + " is been subscribed:" + subscribedChannels);
	}

	/**
	 * 取消订阅频道时的回调
	 */
	@Override
	public void onUnsubscribe(String channel, int subscribedChannels) {
		System.out.println("channel:" + channel + "is been unsubscribed:" + subscribedChannels);
	}

	/**
	 * 取消订阅模式时的回调
	 */
	@Override
	public void onPUnsubscribe(String pattern, int subscribedChannels) {
		// TODO Auto-generated method stub
		super.onPUnsubscribe(pattern, subscribedChannels);
	}

	/**
	 * 订阅频道模式时的回调
	 */
	@Override
	public void onPSubscribe(String pattern, int subscribedChannels) {
		// TODO Auto-generated method stub
		super.onPSubscribe(pattern, subscribedChannels);
	}

}
